var fs = require('fs');

index = 'mr'
console.log(" begin");
let databuf = fs.readFileSync(".\\data.json")
//console.log(databuf.toString());
data = JSON.parse(databuf.toString())

var es = require('./es')
async function importdata(data) {
    for (let i = 0; i < data.length; i++) {
        let r = await es.addDocument(index, data[i]['ID'], data[i])
        console.log(i / data.length);
    }
}


//curl -H "Content-Type: application/x-ndjson"  -s -XPOST "localhost:9200/mr/fs/_bulk?pretty&refresh" --data-binary "@.\data.json


//es.search('mr', '陈征', 'Doctor.编码员')

importdata(data)
console.log(data.length);